package com.briup.cms.dao;

import com.briup.cms.bean.extend.RolePrivilegeExtend;
import com.briup.cms.bean.RolePrivilege;
import org.apache.ibatis.annotations.*;

import java.util.List;

public interface RolePrivilegeMapper {
    @Results({
            @Result(column="role_id",property="roleId"),
            @Result(column="privilege_id",property = "privilegeId"),
            @Result(column="role_name",property = "roleName")
    })
    @Select("select*from rolePrivilege")
    List<RolePrivilege> selectAll();
    @Insert("insert into rolePrivilege values(null,#{roleId},#{privilegeId})")
    void insert (RolePrivilege rolePrivilege);
    @Update("update rolePrivilege set role_id=#{roleId},privilege_id=#{privilegeId} where id=#{id}")
    void update(RolePrivilege rolePrivilege);
    @Delete("delete from rolePrivilege where id=#{id}")
    void deleteById(Long id);
    @Results({
            @Result(column="role_id",property="roleId"),
            @Result(column="privilege_id",property = "privilegeId"),
            @Result(column="role_name",property = "roleName")
    })
    @Select("select u.*,r.name as role_name from rolePrivilege u left join role r on u.role_id = r.id")
    List<RolePrivilegeExtend> selectAllWithRole();
}
